package com.beadhouse.nurfile.support.service;

import java.text.SimpleDateFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

import com.beadhouse.common.exeption.BeadHouseException;
import com.beadhouse.entity.NursingFileEntity;
import com.beadhouse.nurfile.ao.AddNurFileAO;
import com.beadhouse.nurfile.ao.NursingFileAO;
import com.beadhouse.nurfile.ao.SelectNurFileAO;
import com.beadhouse.nurfile.dao.NursingFileDao;
import com.beadhouse.nurfile.service.NursingFileService;
@Service
public class NursingFileServiceImpl implements NursingFileService {
	
	NursingFileDao ndao;
	public NursingFileServiceImpl(NursingFileDao ndao) {
		this.ndao=ndao;
	}
	
	public NursingFileEntity addNursingFile(AddNurFileAO ao) throws Exception {
		
		NursingFileEntity e=new NursingFileEntity();
		SimpleDateFormat sDateFormat=new SimpleDateFormat("yyyy-MM-dd");
		e.setId(ao.getId());
		e.setCustomerId(ao.getCustomerId());
		e.setEndDate(sDateFormat.parse(ao.getEndDate()));
		e.setNurBy(ao.getNurBy());
		e.setNurContent(ao.getNurContent());
		e.setNurType(ao.getNurType());
		e.setStartDate(sDateFormat.parse(ao.getStartDate()));
		e.setUpdateBy(ao.getUpdateBy());
		ndao.insert(e);
		return e;
	}
	
	
	public List<NursingFileEntity> selectNursingFile(SelectNurFileAO ao) throws Exception {
		Integer CustomerId=ao.getCustomerId();
		if(CustomerId==null) {
			throw new BeadHouseException("客户id为空");
		}
		List<NursingFileEntity> s=ndao.selectList(CustomerId);
		return s;
	}
	
	@Override
	public void addCustomerLevel(int levelId, int customerId) throws Exception {
		
		ndao.insertCustomerLevel(levelId, customerId);
	}
	
}
